//
// Created by xili on 2024/8/24 13:57.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    bool checkDistances(string s, vector<int> &distance) {
        int n = s.size();
        unordered_map<char, int> ump;
        for (int i = 0; i < n; i++) {
            if (ump.count(s[i]) && (i - ump[s[i]] - 1 != distance[s[i] - 'a'])) {
                return false;
            }
            ump[s[i]] = i;
        }
        return true;
    }
};